package mybatis.plugins.transaction;

import mybatis.session.TransactionIsolationLevel;
import mybatis.transaction.Transaction;
import mybatis.transaction.TransactionFactory;

import javax.sql.DataSource;
import java.sql.Connection;

public class SpringManagedTransactionFactory implements TransactionFactory {
    @Override
    public Transaction newTransaction(Connection connection) {
        throw new UnsupportedOperationException("New Spring transactions require a DataSource");
    }

    @Override
    public Transaction newTransaction(DataSource dataSource, TransactionIsolationLevel level, boolean autoCommit) {
        return new SpringManagedTransaction(dataSource);
    }
}
